fix(script): keep client-computed SHA-1 in Script.Load - #3943
Open
saddamr3e wants to merge 1 commit into
Open
Conversation
Member
|
Thank you for the contribution @saddamr3e, To set expectations - I review it once we release the GA version so it won't make it in 9.22. |
Contributor
Author
|
Sounds good, no rush. I'll keep the branch up to date in the meantime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reproducer with a Scripter whose SCRIPT LOAD answers with a digest of its own choosing:
NewScript computes hex(sha1(src)) so EVALSHA stays pinned to that script body, but Load overwrote it with the server's string. One reply repoints every later Run/RunRO on that *Script at whatever Lua the peer has cached under the returned digest, running with the caller's keys and ARGV, and EVALSHA still reports success.
Overwriting is only correct for NewScriptServerSHA, where the assignment came from in #3700; kept it on that path and made the client-side-SHA path report the mismatch instead.
Note
Medium Risk
Touches Redis script execution identity (EVALSHA digests), which can affect correctness if callers relied on the old overwrite behavior; scope is limited to Script.Load and well-covered by tests.
Overview
Script.Loadno longer replaces the client-side digest for scripts created withNewScript. It keeps the locally computed SHA-1 of the script source and errors ifSCRIPT LOADreturns a different digest, so laterRun/RunRO/EVALSHAstay tied to that script body instead of whatever Lua the server has under a mismatched hash.NewScriptServerSHAbehavior is unchanged:Loadstill adopts the digest returned by Redis. Tests cover mismatch handling, matching digests, server-SHA adoption, and EVALSHA / EVALSHA_RO digest selection via an extendedfakeScripter.Reviewed by Cursor Bugbot for commit b476f8a. Bugbot is set up for automated code reviews on this repo. Configure here.